package com.sjhang.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sjhang.entity.TbArticleType;
import com.sjhang.mapper.TbArticleTypeMapper;
import com.sjhang.service.TbArticleTypeService;
import com.sjhang.utils.ListParamVo;
import com.sjhang.utils.ResultResponse;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 技术文章类型表  服务实现类
 *
 */
@Service
public class TbArticleTypeServiceImpl extends ServiceImpl<TbArticleTypeMapper, TbArticleType> implements TbArticleTypeService {

    @Resource
    private TbArticleTypeMapper tbArticleTypeMapper;


    /***
     * @description 查询全部分类
     * @params [listParamVo]
     */
    @Override
    public ResultResponse selectArticleType(ListParamVo listParamVo) {
        Page<TbArticleType> tbArticleTypePage = tbArticleTypeMapper.selectPage(
                new Page<TbArticleType>(listParamVo.getCurrent(), listParamVo.getSize()),null);

        return ResultResponse.SUCCESS(tbArticleTypePage);
    }

    /***
     * @description 删除分类信息
     */
    @Override
    public ResultResponse deleteArticleType(Long typeId) {
        tbArticleTypeMapper.deleteById(typeId);
        return ResultResponse.SUCCESS();
    }

    /***
     * @description 修改分类信息
     */
    @Override
    public ResultResponse updateArticleType(TbArticleType listParamVo) {
        tbArticleTypeMapper.updateById(listParamVo);
        return ResultResponse.SUCCESS();
    }

    /***
     * @description 新增一个分类
     * @params [listParamVo]
     */
    @Override
    public ResultResponse insertArticleType(TbArticleType listParamVo) {
        tbArticleTypeMapper.insert(listParamVo);
        return ResultResponse.SUCCESS();
    }
}
